'use strict';

const axios = require('axios').default;

const BASE_URL =
  process.env.DG_CLI_REQUEST_BASE_URL || 'http://dg-server.com:7001';

const request = axios.create({
  baseURL: BASE_URL,
  timeout: 5000
});

request.interceptors.response.use(
  (response) => {
    if (response.status === 200) {
      return response.data;
    }
  },
  (error) => Promise.reject(error)
);

module.exports = request;
